﻿//显示
function BOX_show(e) 
{   
    if(document.getElementById(e)==null){return;}
    BOX_layout(e);
    window.onresize = function(){BOX_layout(e);} //改变窗体重新调整位置
    window.onscroll = function(){BOX_layout(e);} //滚动窗体重新调整位置

    //捕获ESC按键(兼容ie和firefox)
    //document.onkeydown=function(eve){
    //	var k=window.event?event.keyCode:eve.which;
    //	if (k == 27){
    //		BOX_remove(e);
    //	}
    //}
    
    //var PopTagSelect=document.getElementsByTagName("select");//兼容ie6,隐藏所有select
    //for(i=0;i<PopTagSelect.length;i++){
    //    PopTagSelect[i].style.display="none";
    //}
}

//移除
function BOX_remove(e)
{   
    document.getElementById('BOX_overlay').style.display="none";
    document.getElementById(e).style.display="none";
//    $("#"+e).remove();
    //$("#BOX_overlay").remove();
    window.onscroll = null;
    window.onresize = null;

    var PopTagSelect=document.getElementsByTagName("select");//兼容ie6,显示所有select
    for(i=0;i<PopTagSelect.length;i++){
        PopTagSelect[i].style.display="";
    }
}

//调整布局
function BOX_layout(e)
{
    var a = document.getElementById(e);
    
    //判断是否新建遮掩层
    if (document.getElementById('BOX_overlay')==null)
    { 
        var overlay = document.createElement("div");
        overlay.setAttribute('id','BOX_overlay');
        a.parentNode.appendChild(overlay);
    }
    //alert(a.style.width + "," + a.style.height);
    //alert("clientWidth:" + window.parent.innerWidth + ",clientHeight:" + window.parent.innerHeight);
    //取客户端左上坐标，宽，高
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    var clientWidth = document.documentElement.clientWidth;
    var clientHeight = document.documentElement.clientHeight;
    var bo = document.getElementById('BOX_overlay');
    bo.style.left = scrollLeft+'px';
    bo.style.top = scrollTop+'px';
    bo.style.width = clientWidth+'px';
    bo.style.height = clientHeight+'px';
    bo.style.display="";
    bo.innerHTML='<iframe style="position:absolute; top:0; left:0;border:0; width:100%; height:100%; filter:alpha(opacity=0);"></iframe>'
    //Popup窗口定位
    a.style.position = 'absolute';
    a.style.zIndex=98;
    a.style.display="";
    a.style.background = "#ffffff";
//  a.style.width = "100%";
//  a.style.width = clientWidth+'px';
//    a.style.filter = "alpha(opacity=80)";
//  a.style.height = "100%";
//  a.style.height =  clientHeight+'px';
//	a.style.top = 0;
//	a.style.left = 0;
 
    //a.style.left = "40%";
    //a.style.top = "40%";
    //a.style.left = ((document.documentElement.clientWidth - 780) / 2) + "px";
    //a.style.top = "-10px";
    
    document.getElementById('setting').style.display="block";
    a.style.left = ((document.documentElement.clientWidth - a.clientWidth) / 2) + "px";
    var top = (parseInt((document.documentElement.clientHeight - a.clientHeight - 200) / 2));
    top = parseInt((document.documentElement.clientHeight - a.clientHeight - 200) / 2);  
    if(top < 20)
        top = 40;
    top += document.documentElement.scrollTop;
    a.style.top = top + "px";
}


//判断文件扩展名是否合法
function CheckFileExt(FileName){
	var StrAll=FileName;
	if(StrAll!=""){
		var StrExt=StrAll.substring(StrAll.lastIndexOf(".")+1,StrAll.length).toLowerCase();
		if(StrExt=="jsp"||StrExt=="js"||StrExt=="class"||StrExt=="exe"||StrExt=="com"){
			alert('不允许上传此类型文件！');
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}

//将日期时间转化为数字格式
function ChangeTimeFormat(OrgTime){
	var oTime=OrgTime;
	oTime=oTime.replace(/-/g,'');
	oTime=oTime.replace(/ /,'');
	oTime=oTime.replace(/:/,'');
	return oTime;
}